import {ElMessageBoxOptions} from "element-plus/es/components/message-box/src/message-box.type";

const info = async (message: string, title: string = '提示', options: ElMessageBoxOptions = {}) => {
    try {
        options.confirmButtonText = '确定';
        await ElMessageBox.alert(message, title, options);
    } catch (error) {
        // 处理异常
    }
}

const error = async (message: string, title: string = '错误', options: ElMessageBoxOptions = {}) => {
    try {
        options.confirmButtonText = '确定';
        options.type = 'error'
        await ElMessageBox.alert(message, title, options);
    } catch (error) {
        // 处理异常
    }
}

const yesNo = async (message: string, title: string = '提示', options: ElMessageBoxOptions = {}) => {
    try {
        options.confirmButtonText = '确认';
        options.cancelButtonText = '取消';
        options.type = 'warning';

        const result = await ElMessageBox.confirm(
            message,
            title,
            options
        );
        return result == 'confirm';

    } catch (e) {
        return false;
    }
}


export default {info, error, yesNo}
